package com.xuelang.pipeline.client.resource;

import com.xuelang.pipeline.client.common.request.PageParam;
import com.xuelang.pipeline.client.common.result.ApiResult;
import com.xuelang.pipeline.client.common.result.PageRecord;
import com.xuelang.pipeline.client.resource.dto.EnvironmentDTO;
import com.xuelang.pipeline.client.resource.dto.EnvironmentQuery;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;
import java.util.List;

/**
 * 环境服务API
 *
 * @author xiwen.zxg
 * @since 2024/5/15
 */
public interface IEnvironmentService {

    /**
     * 查询环境列表(有过滤条件，可以分页)
     *
     * @param dtoPageParam
     * @return
     */
    @PostMapping(value = "/pageList", produces = "application/json;charset=utf-8")
    ApiResult<PageRecord<EnvironmentDTO>> pageEnvironmentList(@RequestBody @Valid PageParam<EnvironmentQuery> dtoPageParam);

    /**
     * 查询环境列表(有过滤条件)
     *
     * @param environmentQuery
     * @return
     */
    @PostMapping(value = "/list", produces = "application/json;charset=utf-8")
    ApiResult<List<EnvironmentDTO>> conditionalEnvironmentList(@RequestBody @Valid EnvironmentQuery environmentQuery);

    /**
     * 根据关键字（环境名称）查询环境数组
     * @param keyword
     * @return
     */
    @GetMapping(value = "/listEnvironmentByKeyword",  produces = "application/json;charset=utf-8")
    ApiResult<List<EnvironmentDTO>> listEnvironmentByKeyword(@RequestParam("keyword") String keyword);

    /**
     * 新增环境
     *
     * @param environmentDTO
     * @return
     */
    @PostMapping(value = "", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> addEnvironment(@RequestBody @Valid EnvironmentDTO environmentDTO);

    /**
     * 更新环境
     *
     * @param environmentDTO
     * @return
     */
    @PutMapping(value = "", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> updateEnvironment(@RequestBody @Valid EnvironmentDTO environmentDTO);

    /**
     * 删除环境
     *
     * @param uuid
     * @return
     */
    @DeleteMapping(value = "/{uuid}", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> deleteEnvironment(@PathVariable("uuid") String uuid);

    /**
     * 该环境是否存在关联流水线
     *
     * @param environmentUuid
     * @return
     */
    @GetMapping(value = "/existsPipeline/{environmentUuid}", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> existsPipelineByEnvironment(@PathVariable("environmentUuid") String environmentUuid);
    /**
     * 查询环境
     *
     * @param uuid
     * @return
     */
    @GetMapping(value = "/{uuid}", produces = "application/json;charset=utf-8")
    ApiResult<EnvironmentDTO> queryEnvironment(@PathVariable("uuid") String uuid);
}
